Skip to content

feat: add Test Connection button to SSH profile editor#437

Merged
datlechin merged 1 commit intomainfrom
feat/ssh-profile-test-connection
Mar 23, 2026
Merged

feat: add Test Connection button to SSH profile editor#437
datlechin merged 1 commit intomainfrom
feat/ssh-profile-test-connection

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

@datlechin datlechin commented Mar 23, 2026

Summary

Closes #436.

  • Add a Test Connection button in the SSH profile editor that validates SSH connectivity (TCP connect, handshake, host key verification, authentication) without creating a full tunnel
  • Extract shared buildAuthenticatedChain() helper in LibSSH2TunnelFactory to eliminate jump-host logic duplication between createTunnel and testConnection
  • Handle edge cases: task cancellation on sheet dismiss, TOTP prompt-at-connect mode skipped during test, jump host changes reset test state

Test plan

  • Open SSH profile editor, enter valid SSH details, click Test Connection — verify green checkmark
  • Enter invalid host/credentials, click Test Connection — verify error dialog with details
  • Change any field after successful test — verify checkmark resets
  • Add/remove a jump host after successful test — verify checkmark resets
  • Set TOTP to "Prompt at Connect", click Test Connection — verify no blocking modal appears
  • Dismiss sheet while test is in progress — verify no error dialog appears after dismiss
  • Test with jump hosts configured — verify multi-hop connectivity is validated

Summary by CodeRabbit

  • New Features

    • Added a "Test Connection" button to the SSH profile editor for validating SSH connectivity separately from tunnel creation. The button displays a progress indicator while testing and shows success or failure status.
  • Documentation

    • Added guidance on testing SSH profiles and troubleshooting SSH connectivity issues.

@datlechin datlechin merged commit d609e74 into main Mar 23, 2026
2 of 3 checks passed
@datlechin datlechin deleted the feat/ssh-profile-test-connection branch March 23, 2026 12:44
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 23, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c3edae05-4fcf-42b3-9d2c-6c1048a05173

📥 Commits

Reviewing files that changed from the base of the PR and between ebcded6 and f015f5b.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • TablePro/Core/SSH/LibSSH2TunnelFactory.swift
  • TablePro/Core/SSH/SSHTunnelManager.swift
  • TablePro/Views/Connection/SSHProfileEditorView.swift
  • docs/databases/ssh-tunneling.mdx
  • docs/features/ssh-profiles.mdx

📝 Walkthrough

Walkthrough

This PR adds a "Test Connection" feature to the SSH profile editor. The implementation extracts tunnel authentication logic into a reusable chain-building mechanism in LibSSH2TunnelFactory, exposes it through a new manager method in SSHTunnelManager, and integrates it into the profile editor UI with state management and user feedback. Resource cleanup is centralized to avoid leaks during testing.

Changes

Cohort / File(s) Summary
Core SSH Tunnel Factory
TablePro/Core/SSH/LibSSH2TunnelFactory.swift
Refactored tunnel setup by extracting authentication chain building into new buildAuthenticatedChain(...) method. Added public testConnection(config:credentials:) API for connection validation. Introduced cleanupChain(...) for centralized resource teardown (session disconnect, socket closure, relay cancellation, hop cleanup). Updated createTunnel(...) to use the new chain-building pattern.
SSH Tunnel Manager
TablePro/Core/SSH/SSHTunnelManager.swift
Added async method testSSHProfile(config:credentials:) that delegates to LibSSH2TunnelFactory.testConnection(...) within a detached task, enabling connection testing without creating persistent tunnels.
SSH Profile Editor UI
TablePro/Views/Connection/SSHProfileEditorView.swift
Integrated connection testing with new state tracking (isTesting, testSucceeded, testTask). Added "Test Connection" button with progress indicator and success/failure feedback. Implemented testSSHConnection() to call the manager, handle errors, and display result sheets. Resets test state when profile inputs change and cancels in-flight tasks on view dismissal.
Documentation
docs/databases/ssh-tunneling.mdx, docs/features/ssh-profiles.mdx
Added troubleshooting guidance and new "Testing a Profile" section explaining the Test Connection workflow and expected outcomes.
Changelog
CHANGELOG.md
Documented the new Test Connection feature.

Sequence Diagram

sequenceDiagram
    participant User as User
    participant Editor as SSHProfileEditorView
    participant Manager as SSHTunnelManager
    participant Factory as LibSSH2TunnelFactory
    participant SSH as SSH Server

    User->>Editor: Click "Test Connection"
    activate Editor
    Editor->>Editor: Set isTesting = true
    Editor->>Manager: testSSHProfile(config, credentials)
    deactivate Editor
    
    activate Manager
    Manager->>Factory: testConnection(config, credentials)
    deactivate Manager
    
    activate Factory
    Factory->>Factory: buildAuthenticatedChain()
    Factory->>SSH: Connect & Authenticate
    activate SSH
    SSH-->>Factory: Connection established
    deactivate SSH
    
    Factory->>Factory: cleanupChain()
    Factory->>SSH: Disconnect
    deactivate Factory
    
    activate Editor
    Editor->>Editor: Set testSucceeded = true
    Editor->>User: Show success feedback
    deactivate Editor
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 A hop, a chain, a test so clean,
No tunnel made, yet SSH's seen—
Connect, shake hands, then fade away,
Green checkmark dances, hip hooray!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ssh-profile-test-connection

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add Test Connection Option to SSH Profile Editor

1 participant